#pragma once
#include "ixamlschemaobject.h"

#include "XStringBuilder.h"





class XamlText :
	public IXamlSchemaObject
{

public: 
	XamlText(XBOOL bPreserveSpace);
	HRESULT Reset(XBOOL bPreserveSpace);
	HRESULT Initialize(const CXString & rstrString);
	HRESULT Initialize(const XCHAR * pBuffer, XUINT32 cBuffer);
	HRESULT Initialize(XUINT32 uInitialSize);
	HRESULT Paste(const xshared_ptr<CXString> & inText, XBOOL bTrimLeadingWhitespace);
	HRESULT get_IsEmpty(XBOOL & bIsEmpty);
	HRESULT get_Text(xshared_ptr<CXString> & spText);
	HRESULT set_Text(const xshared_ptr<CXString> & spText);
	HRESULT get_AttributeText(xshared_ptr<CXString> &);
	HRESULT get_IsSpacePreserved(XBOOL & bIsSpacePreserved);
	HRESULT get_IsWhiteSpaceOnly(XBOOL & bIsWhiteSpaceOnly);
	HRESULT get_LooksLikeAMarkupExtension(XBOOL & bLooksLikeMarkupExtension);
	HRESULT UnescapeMEEscapingIfRequired();
	static HRESULT TrimWhitespace(const xshared_ptr<CXString> & spText, XBOOL bTrimStart, XBOOL bTrimEnd, xshared_ptr<CXString> & spTrimmed);
private: 
	XBOOL PrivateIsEmpty();
	XBOOL PrivateLooksLikeMarkupExtension();
	XBOOL PrivateIsMarkupEscaping();
	HRESULT AppendToBuffer(const XCHAR ch);
	HRESULT AppendToBuffer(const xshared_ptr<CXString> & chs);
	HRESULT CopyBufferSubString(xshared_ptr<CXString> & outssSubString, XUINT32 uStartIndex);
	static XBOOL IsWhitespaceChar(XCHAR ch);
	static XBOOL IsWhitespace(const xshared_ptr<CXString> & spText);
	static HRESULT CollapseWhitespace(const xshared_ptr<CXString> & spText, xshared_ptr<CXString> & spCollapsed);
	XBOOL m_bPreserveSpace;
	XBOOL m_bIsAllWhiteSpace;
	XStringBuilder m_Builder;  

};


